<?php
include_once '../../include/dbconf.php';
function list_menu(){
	global $db;
	$list=$db->get_results("select id,menu_name,menu_parent_id,menu_url from menu;",true);
	return $list;
}
function  get_menu_list_by_id($id){
	global $db;
	$list=$db->get_results("select id,menu_name,menu_parent_id,menu_url from menu where id=$id",true);
	return $list;
}

/**
 *
 * Enter description here ...
 * @param   $id
 * @param   $parent_id
 * @param   $catlog_name
 */
function  menu_update($id,$parent_id,$menu_name,$menu_url){
	global $db;
	$sql="update  menu   set menu_parent_id=$parent_id, menu_name='$menu_name',menu_url='$menu_url' where id=$id";
 	$list=$db->query($sql,true);
	return $list>0;
}
/**
 * 
 * Enter description here ...
 * @param   $id
 * @param   $parent_id
 * @param   $catlog_name
 */
function  menu_add($parent_id,$catlog_name,$menu_url){
	global $db;
	$sql="insert into  menu(menu_parent_id,menu_name,menu_url) values ($parent_id,'$catlog_name','$menu_url') ";
 	$list=$db->query($sql,true);
	return $list>0;
}

/**
 *delete catalog by id
 *
 * @param   $id
 */
function  menu_delete($id){
	global $db;
	$list=$db->query("delete from menu where id=$id",true);
	return $list>0;
}

function  get_menu_list_by_parent_id($id){
	global $db;
	$list=$db->get_results("select id,menu_name,menu_parent_id,menu_url from menu where menu_parent_id=$id ",true);
	return $list;
}
?>